package com.xxx.video.login.activitys;

import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.xxx.video.R;
import com.xxx.video.commen.activitys.BaseActivity;
import com.xxx.video.commen.utils.FontCacheUtils;
import com.xxx.video.commen.utils.StatusBarUtil;
import com.xxx.video.commen.utils.StringUtils;
import com.xxx.video.commen.utils.ToastUtils;
import com.xxx.video.commen.views.FontTextView;
import com.xxx.video.login.presenters.ForgetPwdSecondPresenter;
import com.xxx.video.login.presenters.IForgetPwdSecondView;

import butterknife.BindView;
import butterknife.OnClick;

public class ForgetPwdSecondActivity extends BaseActivity<ForgetPwdSecondPresenter> implements IForgetPwdSecondView {

    @BindView(R.id.et_forget_pwd_second_new_pwd)
    EditText etForgetPwdSecondNewPwd;
    @BindView(R.id.et_forget_pwd_second_new_pwd_again)
    EditText etForgetPwdSecondNewPwdAgain;
    /**
     * user name
     */
    private String mUserName;

    @Override
    public void initToolbarData() {
        super.initToolbarData();
        showActionBar();
        StatusBarUtil.getInstance().setStatusBarTransparent(this, true);
        setActionBarTitle(R.string.title_forget_second_activity);
        setIsShowActionbarLine(true);
        Typeface customFont = FontCacheUtils.getInstance().getTypeface(FontTextView.ttf3, this);
        etForgetPwdSecondNewPwd.setTypeface(customFont);
        etForgetPwdSecondNewPwdAgain.setTypeface(customFont);
    }

    @Override
    protected ForgetPwdSecondPresenter createPresenter() {
        return new ForgetPwdSecondPresenter(this, this);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_forget_pwd_second;
    }

    @Override
    public void initData(Bundle extras) {
        showLayoutStatus(1);
        if (extras != null) {
            mUserName = extras.getString("userName");
        }
    }


    @OnClick({R.id.tv_forget_pwd_second_save})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_forget_pwd_second_save:
                getPresenter().forgetPassword(mUserName);
                break;
            default:
                break;
        }
    }

    @Override
    public void showRootLayoutStatus(int status) {
        showLayoutStatus(status);
    }

    @Override
    public String getPwd() {
        return etForgetPwdSecondNewPwd.getText().toString().trim();
    }

    @Override
    public String getPwdAgain() {
        return etForgetPwdSecondNewPwdAgain.getText().toString().trim();
    }

    @Override
    public void forgetPwdSuccess() {
        ToastUtils.showSuccess(StringUtils.getInstance().getString(R.string.tip_forget_pwd_second_edit_pwd_success));
        setResult(RESULT_OK);
        finish();
    }
}
